package com.noodles.decent.videoplayer;

import android.graphics.Bitmap;
import android.media.ThumbnailUtils;
import android.provider.MediaStore;
//import android.icu.text.SimpleDateFormat;

import java.util.Date;
import java.text.SimpleDateFormat;
/**
 * Created by Administrator on 2017/6/19.
 */

public class VideoItem {

    String name;
    String path;
    Bitmap thumb;
    String createdTime;

    VideoItem(String strPath,String strName,String createdTime){
        //视频位置保存
        this.path=strPath;
        //视频标题保存
        this.name=strName;

        //Unix时间转换
        SimpleDateFormat sf=new SimpleDateFormat("yy年MM月dd日HH时mm分");
        Date d=new Date(Long.valueOf(createdTime)*1000);
        this.createdTime=sf.format(d);
    }

    //视频缩略图
    void createThumb(){
        if(this.thumb==null){
            this.thumb=ThumbnailUtils.createVideoThumbnail(this.path,MediaStore.Images.Thumbnails.MINI_KIND);
        }
    }

    void releaseThumb(){
        if(this.thumb!=null){
            this.thumb.recycle();
            this.thumb=null;
        }
    }

    @Override
    public boolean equals(Object o){
        VideoItem another=(VideoItem) o;

        return another.path.equals(this.path);
    }
}
